Determining a Compressor s Output Format

The following example uses the ICCompressGetFormatFBZQJ9 size macro to determine the buffer size needed for the data specifying the compression format, allocates a buffer of the appropriate size using the GlobalAllocF12W9. function, and retrieves the compression format information using the ICCompressGetFormatFBZQJ9 macro.

LPBITMAPINFOHEADER     lpbiIn, lpbiOut;

 

// *lpbiIn must be initialized to the input format.

 

dwFormatSize = ICCompressGetFormatSize(hIC, lpbiIn);

h = GlobalAlloc(GHND, dwFormatSize);

lpbiOut = (LPBITMAPINFOHEADER)GlobalLock(h);

ICCompressGetFormat(hIC, lpbiIn, lpbiOut);

 

The following example uses the ICCompressQuery1NJRUWL macro to determine whether a compressor can handle the input and output formats.

LPBITMAPINFOHEADER     lpbiIn, lpbiOut;

 

// Both *lpbiIn and *lpbiOut must be initialized to the respective
// formats.

 

if (ICCompressQuery(hIC, lpbiIn, lpbiOut) == ICERR_OK)

 

    // Format is supported; use the compressor.

 

}

 

The following example uses the ICCompressGetSize653IRE macro to determine the buffer size, and it allocates a buffer of that size using GlobalAllocF12W9..

// Find the worst-case buffer size.

dwCompressBufferSize = ICCompressGetSize(hIC, lpbiIn, lpbiOut);

 

// Allocate a buffer and get lpOutput to point to it.

h = GlobalAlloc(GHND, dwCompressBufferSize);

lpOutput = (LPVOID)GlobalLock(h);